<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
    <title>ShellCheck: SC2192 – This array element has no value. Remove spaces after `=` or use `""` for empty string.</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
  </head>
  <body style="margin-left: auto; margin-right: auto; max-width: 800px">
    <h1>SC2192 – ShellCheck Wiki</h1>
    <a href="https://github.com/koalaman/shellcheck/wiki/SC2192">See this page on GitHub</a>
    <p style="display: none"><a href="index.html">Sitemap</a></p>
    <hr />
    <h2
id="this-array-element-has-no-value-remove-spaces-after--or-use--for-empty-string">This
array element has no value. Remove spaces after <code>=</code> or use
<code>""</code> for empty string.</h2>
<h3 id="problematic-code">Problematic code:</h3>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="SC2192.html#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="va">array</span><span class="op">=</span><span class="va">(</span><span class="op">[</span><span class="dv">1</span><span class="op">]</span><span class="va">=</span>one <span class="op">[</span><span class="dv">2</span><span class="op">]</span><span class="va">=</span> two<span class="va">)</span></span></code></pre></div>
<h3 id="correct-code">Correct code:</h3>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="SC2192.html#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="va">array</span><span class="op">=</span><span class="va">(</span><span class="op">[</span><span class="dv">1</span><span class="op">]</span><span class="va">=</span>one <span class="op">[</span><span class="dv">2</span><span class="op">]</span><span class="va">=</span>two<span class="va">)</span></span></code></pre></div>
<h3 id="rationale">Rationale:</h3>
<p>You have an array element on the form <code>[index]=</code>. The
shell will interpret this as an independent element with index
<code>index</code> and value <code>&lt;empty string&gt;</code>.</p>
<p>This may happen as part of the expression
<code>[index]= value</code>, where the space is not allowed and causes
the shell to interpret it as
<code>[index]="" [index+1]=value</code>.</p>
<p>If you wanted the element to have a value, remove the spaces after
<code>=</code>, e.g. <code>[index]=value</code>.</p>
<p>If you wanted to assign an empty string, explicitly use empty quotes:
<code>[index]=""</code>. This makes no difference to the shell, but will
make your intention clear to shellcheck and other humans.</p>
<h3 id="exceptions">Exceptions:</h3>
<p>None.</p>
    <hr />
    <p style='font-size: 80%'><a href="../index.html">ShellCheck</a> is a static analysis tool for shell scripts. This page is part of its documentation.</p>
  </body>
</html>


